<?php
class News_Model extends General_Model {

	function getnew() {
		$query = $this->db->get ( 'news' );
		$list = $query->result_array();
		return $list;
	}

	function getlastestnew() {
		$query = $this->db->query ( 'SELECT * FROM `ci_news` ORDER BY createdtime DESC LIMIT 0,6' );
		$list = $query->result_array();
		return $list;
	}

	function getDetail($id) {
		$this->db->where ( 'id', $id );
		$query = $this->db->get ( 'news' );
		$detail = $query->result_array();
		return $detail;
	}
	function getOtherNew($id){
		$query=$this->db->query("SELECT * FROM `ci_news` WHERE id <> '$id'");
		$list = $query->result_array();
		return $list;
	}

	function del($id) {
		$this->db->where ( 'id', $id );
		$this->db->limit ( 1, 0 );
		$this->db->delete ( 'news' );
		return TRUE;
	}

	function save_new_sua($data,$id) {

	 $ten = $data['ten_news'];
	 $ten_en = $data['ten_news_en'];
	 $content = $data['news_content'];
	 $content_en = $data['news_content_en'];
	 $query_new = "update ci_news set ten_news='".$ten."', ten_news_en='".$ten_en."', news_content='".$content."', news_content_en='".$content_en."' where id='".$id."'";
	 $this->db->query($query_new);


	}
}